package net;

import java.util.LinkedList;

public class Queue<T>{

    private final LinkedList<T> linkedList;

    public Queue()
    {
        linkedList = new LinkedList<>();
    }

    public boolean enqueue(T t)
    {
        if(t != null)
        {
            linkedList.addLast(t);
            return true;
        }

        return false;

    }

    public T dequeue()
    {
        T t = peek();
        if(t != null)
            linkedList.removeFirst();
        return t;
    }

    public T peek()
    {
        T t = null;
        if(!linkedList.isEmpty())
            t = linkedList.getFirst();
        return t;
    }

    public int size()
    {
        return linkedList.size();
    }

    public boolean isEmpty()
    {
        return linkedList.isEmpty();
    }
}
